cmake_minimum_required(VERSION 3.5)

project(ApplicationDemo VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

include_directories(D:/Art/include)
link_directories(d:/Art/Lib/x64)

include_directories(./include)
link_directories(./lib)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Network)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Sql)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Xml Charts)

set(PROJECT_SOURCES
        main.cpp
        mainwindow.cpp
        mainwindow.h
        mainwindow.ui
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
    qt_add_executable(ApplicationDemo
        MANUAL_FINALIZATION
        ${PROJECT_SOURCES}
        resources.qrc
        projectmanager.h projectmanager.cpp
        newprojectdialog.h newprojectdialog.cpp newprojectdialog.ui
        diagram/arrow.h diagram/diagramitem.h diagram/diagramscene.h diagram/diagramtextitem.h
        diagram/arrow.cpp diagram/diagramitem.cpp diagram/diagramscene.cpp diagram/diagramtextitem.cpp
        charts/contentwidget.cpp charts/contentwidget.h charts/mainwidget.cpp charts/mainwidget.h
        charts/areawidget.cpp charts/areawidget.h charts/barmodelmappermodel.cpp charts/barmodelmappermodel.h
        charts/barmodelmapperwidget.cpp charts/barmodelmapperwidget.h
        charts/barwidget.cpp charts/barwidget.h
        charts/barpercentwidget.cpp charts/barpercentwidget.h
        charts/barstackedwidget.cpp charts/barstackedwidget.h
        charts/horizontalbarwidget.cpp charts/horizontalbarwidget.h
        charts/horizontalpercentbarwidget.cpp charts/horizontalpercentbarwidget.h
        charts/horizontalstackedbarwidget.cpp charts/horizontalstackedbarwidget.h
        charts/boxplotdatareader.cpp charts/boxplotdatareader.h charts/boxplotwidget.cpp charts/boxplotwidget.h
        charts/callout.cpp charts/callout.h charts/calloutview.cpp charts/calloutview.h charts/calloutwidget.cpp charts/calloutwidget.h
        charts/candlestickdatareader.cpp charts/candlestickdatareader.h charts/candlestickwidget.cpp charts/candlestickwidget.h
        charts/interactionschart.cpp charts/interactionschart.h charts/interactionsview.cpp charts/interactionsview.h charts/interactionswidget.cpp charts/interactionswidget.h
        charts/contentwidget.h charts/customchartwidget.cpp charts/customchartwidget.h charts/datetimeaxiswidget.cpp charts/datetimeaxiswidget.h charts/donutbreakdownchart.cpp charts/donutbreakdownchart.h charts/donutbreakdownmainslice.cpp charts/donutbreakdownmainslice.h charts/donutbreakdownwidget.cpp charts/donutbreakdownwidget.h charts/donutwidget.cpp charts/donutwidget.h
        charts/dynamicsplinewidget.cpp charts/dynamicsplinewidget.h
        charts/legendmarkerswidget.cpp charts/legendmarkerswidget.h charts/legendwidget.cpp charts/legendwidget.h
        charts/lightmarkerswidget.cpp charts/lightmarkerswidget.h charts/lineandbarwidget.cpp charts/lineandbarwidget.h charts/linewidget.cpp charts/linewidget.h
        charts/logaxiswidget.cpp charts/logaxiswidget.h
        charts/modeldatamodel.cpp charts/modeldatamodel.h charts/modeldatawidget.cpp charts/modeldatawidget.h charts/multiaxiswidget.cpp charts/multiaxiswidget.h
        charts/nesteddonutswidget.cpp charts/nesteddonutswidget.h
        charts/pccbrushtool.cpp charts/pccbrushtool.h charts/pcccustomslice.cpp charts/pcccustomslice.h charts/pccpentool.cpp charts/pccpentool.h charts/pccwidget.cpp charts/pccwidget.h charts/piedrilldownchart.cpp charts/piedrilldownchart.h charts/piedrilldownslice.cpp charts/piedrilldownslice.h charts/piedrilldownwidget.cpp charts/piedrilldownwidget.h charts/piewidget.cpp charts/piewidget.h charts/pointconfigurationwidget.cpp charts/pointconfigurationwidget.h charts/polarchartview.cpp charts/polarchartview.h charts/polarchartwidget.cpp charts/polarchartwidget.h
        charts/scatterinteractionswidget.cpp charts/scatterinteractionswidget.h charts/scatterwidget.cpp charts/scatterwidget.h charts/selectedbarwidget.cpp charts/selectedbarwidget.h charts/splinewidget.cpp charts/splinewidget.h charts/stackeddrilldownchart.cpp charts/stackeddrilldownchart.h charts/stackeddrilldownseries.cpp charts/stackeddrilldownseries.h charts/stackeddrilldownwidget.cpp charts/stackeddrilldownwidget.h charts/temperaturerecordswidget.cpp charts/temperaturerecordswidget.h
        charts/oscilloscopewidget.h charts/oscilloscopewidget.cpp
        charts/mwaveview.cpp charts/mwaveview.h
        charts/mwavewidget.h charts/mwavewidget.cpp
        charts/net8814zwavewidget.h charts/net8814zwavewidget.cpp
        customprogresswidget.cpp customprogresswidget.h
        channelsetupdialog.h channelsetupdialog.cpp channelsetupdialog.ui
        algorithm/Spectrumanalysis.cpp algorithm/Spectrumanalysis.h
        component/fftw3.h
        sampledevicedialog.h sampledevicedialog.cpp sampledevicedialog.ui
        twoprogresstablewidget.cpp twoprogresstablewidget.h
        devicechannel.h devicechannel.cpp
        include/fftw3.h
        include/fftw3.h lib/libfftw3-3.lib lib/libfftw3f-3.lib lib/libfftw3l-3.lib
        mysql.h mysql.cpp
        devicesubchannel.h devicesubchannel.cpp
        hardware/idevice.h hardware/idevice.cpp
        hardware/virtualdevice.h hardware/virtualdevice.cpp
        hardware/net8814zdevice.h hardware/net8814zdevice.cpp
        devicechanneltablewidget.cpp devicechanneltablewidget.h
        core/channel.h core/channel.cpp
        core/calculation.h core/calculation.cpp
        core/calculationitem.h core/calculationitem.cpp
        core/algorithm.h core/algorithm.cpp
        core/meanalgorithm.h core/meanalgorithm.cpp
        core/statisticscalculation.h core/statisticscalculation.cpp
        core/application.qmodel
        core/fouriercalculation.h core/fouriercalculation.cpp
        core/filtercalculation.h core/filtercalculation.cpp

      )

# Define target properties for Android with Qt 6 as:
#    set_property(TARGET ApplicationDemo APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
#                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
    if(ANDROID)
        add_library(ApplicationDemo SHARED
            ${PROJECT_SOURCES}
        )
# Define properties for Android with Qt 5 after find_package() calls as:
#    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
    else()
        add_executable(ApplicationDemo
            ${PROJECT_SOURCES}
        )
    endif()
endif()

target_link_libraries(ApplicationDemo PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
target_link_libraries(ApplicationDemo PRIVATE Qt${QT_VERSION_MAJOR}::Xml)
target_link_libraries(ApplicationDemo PRIVATE Qt${QT_VERSION_MAJOR}::Charts)
target_link_libraries(ApplicationDemo PRIVATE Qt${QT_VERSION_MAJOR}::Network)
target_link_libraries(ApplicationDemo PRIVATE Qt${QT_VERSION_MAJOR}::Sql)
target_link_libraries(ApplicationDemo PRIVATE Art_DAQ_64)
target_link_libraries(ApplicationDemo PRIVATE Art_DAQ_64)
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
  set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.ApplicationDemo)
endif()
set_target_properties(ApplicationDemo PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)


include(GNUInstallDirs)
install(TARGETS ApplicationDemo
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(ApplicationDemo)
endif()
